package ivo.action;

import ivo.pojo.AcarristPO;
import ivo.pojo.AeqptptPO;
import ivo.pojo.AeqptstPO;
import ivo.pojo.DcarrixfPO;
import ivo.pojo.StockerPO;
import ivo.service.impl.CrrService;
import ivo.tx.Amsheart.FbpbistolO;
import ivo.tx.Amsheart.FrpclmxfrO;
import ivo.tx.Amsheart.FrpiqcrrxI;
import ivo.tx.Amsheart.FrpiqcrrxO;
import ivo.tx.Amsheart.FrplststcO;
import ivo.tx.Amsheart.FrplwipeqI;
import ivo.tx.Amsheart.FrplwipeqO;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import net.sf.json.JSONObject;

import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;

@Controller
@Scope("prototype")
public class CrrAction extends ActionSupport{
	private Logger logger = Logger.getLogger(CrrAction.class);
	@Autowired
	private CrrService crrService;
	private AcarristPO crrInfo;
	private List<DcarrixfPO> txfInfolist;
	private List<AcarristPO> crrInfoOnPort;
	private List<DcarrixfPO> dcarrixfPOList;
	private List<StockerPO> stockerlist;
	private List<StockerPO> stkpatilist;
	private List<AeqptstPO> toollist;
	private List<AeqptptPO> toolportlist;
	public List<StockerPO> getStockerlist() {
		return stockerlist;
	}
	public void setStockerlist(List<StockerPO> stockerlist) {
		this.stockerlist = stockerlist;
	}
	private FrpclmxfrO frpclmxfrO;
	//初始化stocker的outtrx
	private FrplststcO frplststcO;
	//初始化toTool
	private FbpbistolO fbpbistolO;
//	private String selData;
	private String strMsg;
	private String iary;
	private JSONObject inTrxObj;
	private String outObj;
	private FrpiqcrrxO frpiqcrrxO;
	private FrpiqcrrxI frpiqcrrxI;
	private FrplwipeqI frplwipeqI;
	private FrplwipeqO frplwipeqO;
	/*
	 * 手动上报卡匣搬送指令
	 */

	public String update(){
		HttpServletRequest request = ServletActionContext.getRequest();
		String strMsg = request.getParameter("strMsg");
		outObj=crrService.update(strMsg);
		return SUCCESS;
	}
	public String initStocker(){
//		HttpServletRequest request = ServletActionContext.getRequest();
//		String strMsg = request.getParameter("strMsg");
		stockerlist=crrService.initStocker();
		return SUCCESS;
	}
	public String initToTool(){
		HttpServletRequest request = ServletActionContext.getRequest();
		String jsonStr = request.getParameter("selData");
		JSONObject jsonObj = JSONObject.fromObject(jsonStr);
		String unitTyp=jsonObj.getString("unit_typ");
		toollist=crrService.inittoTool(unitTyp);
		return SUCCESS;
	}
	public String initStkPatition(){
		HttpServletRequest request = ServletActionContext.getRequest();
		String jsonStr = request.getParameter("selData");
		JSONObject jsonObj = JSONObject.fromObject(jsonStr);
		String stocker_id=jsonObj.getString("stocker_id");
		stkpatilist=crrService.initstkpatition(stocker_id);
		return SUCCESS;
	}
	public String queryCrrXfr(){
		HttpServletRequest request = ServletActionContext.getRequest();
		String jsonStr = request.getParameter("selData");
		JSONObject jsonObj = JSONObject.fromObject(jsonStr);
		String crr_id=jsonObj.getString("crr_id");
		txfInfolist =crrService.queryCrrxfrInfo(crr_id);
		return SUCCESS;
	}
	public String initToToolPort(){
		HttpServletRequest request = ServletActionContext.getRequest();
		String jsonStr = request.getParameter("selData");
		JSONObject jsonObj = JSONObject.fromObject(jsonStr);
		String root_tool_id=jsonObj.getString("root_tool_id");
		toolportlist=crrService.inittoToolPort(root_tool_id);
		return SUCCESS;
	}

	public String queryCrrOnPort(){
		HttpServletRequest request = ServletActionContext.getRequest();
		String jsonStr = request.getParameter("selData");
		//String jsonStr = selData;
		JSONObject jsonObj = JSONObject.fromObject(jsonStr);
		String eqpt_id = jsonObj.getString("eqptID");
		String port_id = jsonObj.getString("portID");
		logger.info("任务开始>CrrOnPort query........eqpt_id : " + eqpt_id + "；port_id：" + port_id);
		crrInfo = crrService.queryCrrInfo(eqpt_id,port_id);
		return SUCCESS;
	}
	
	public String queryCrrInfoOnPort(){
		HttpServletRequest request = ServletActionContext.getRequest();
		String ip = request.getRemoteAddr();
		crrInfoOnPort = crrService.selectAllCrrInfoOnPort();
		return SUCCESS;
	}

	public String loadCrrSort(){
		dcarrixfPOList = crrService.loadCrrSortInfo();
		return SUCCESS;
	}
	
	public AcarristPO getCrrInfo() {
		return crrInfo;
	}

	public List<DcarrixfPO> getDcarrixfPOList() {
		return dcarrixfPOList;
	}

	/*public String getSelData() {
		return selData;
	}*/
	public List<DcarrixfPO> getTxfInfolist() {
		return txfInfolist;
	}
	public void setTxfInfolist(List<DcarrixfPO> txfInfolist) {
		this.txfInfolist = txfInfolist;
	}
	public JSONObject getInTrxObj() {
		return inTrxObj;
	}
	public List<AeqptptPO> getToolportlist() {
		return toolportlist;
	}
	public void setToolportlist(List<AeqptptPO> toolportlist) {
		this.toolportlist = toolportlist;
	}
	public void setInTrxObj(JSONObject inTrxObj) {
		this.inTrxObj = inTrxObj;
	}
	/*public void setSelData(String selData) {
		this.selData = selData;
	}*/
	public List<AcarristPO> getCrrInfoOnPort() {
		return crrInfoOnPort;
	}

	public List<AeqptstPO> getToollist() {
		return toollist;
	}
	public void setToollist(List<AeqptstPO> toollist) {
		this.toollist = toollist;
	}
	public void setCrrInfoOnPort(List<AcarristPO> crrInfoOnPort) {
		this.crrInfoOnPort = crrInfoOnPort;
	}
	public FrpclmxfrO getFrpclmxfrO() {
		return frpclmxfrO;
	}
	public List<StockerPO> getStkpatilist() {
		return stkpatilist;
	}
	public void setStkpatilist(List<StockerPO> stkpatilist) {
		this.stkpatilist = stkpatilist;
	}
	public void setFrpclmxfrO(FrpclmxfrO frpclmxfrO) {
		this.frpclmxfrO = frpclmxfrO;
	}
	public FrplststcO getFrplststcO() {
		return frplststcO;
	}
	public void setFrplststcO(FrplststcO frplststcO) {
		this.frplststcO = frplststcO;
	}
	public FbpbistolO getFbpbistolO() {
		return fbpbistolO;
	}
	public void setFbpbistolO(FbpbistolO fbpbistolO) {
		this.fbpbistolO = fbpbistolO;
	}
	public FrpiqcrrxI getFrpiqcrrxI() {
		return frpiqcrrxI;
	}
	public void setFrpiqcrrxI(FrpiqcrrxI frpiqcrrxI) {
		this.frpiqcrrxI = frpiqcrrxI;
	}
	public FrpiqcrrxO getFrpiqcrrxO() {
		return frpiqcrrxO;
	}
	public void setFrpiqcrrxO(FrpiqcrrxO frpiqcrrxO) {
		this.frpiqcrrxO = frpiqcrrxO;
	}
	public FrplwipeqI getFrplwipeqI() {
		return frplwipeqI;
	}
	public void setFrplwipeqI(FrplwipeqI frplwipeqI) {
		this.frplwipeqI = frplwipeqI;
	}
	public FrplwipeqO getFrplwipeqO() {
		return frplwipeqO;
	}
	public void setFrplwipeqO(FrplwipeqO frplwipeqO) {
		this.frplwipeqO = frplwipeqO;
	}
	public String getOutObj() {
		return outObj;
	}
	public void setOutObj(String outObj) {
		this.outObj = outObj;
	}
	public String getIary() {
		return iary;
	}
	public void setIary(String iary) {
		this.iary = iary;
	}
	public String getStrMsg() {
		return strMsg;
	}
	public void setStrMsg(String strMsg) {
		this.strMsg = strMsg;
	}
	
	
	

}
